<template>
  <Modal
    v-model:active="MeshCheckModalVueActive"
    transfer
    title="单元检查"
    :width="540"
    confirm-text="确定"
    @confirm="excuteMeshCheck"
  >
    <NativeScroll use-y-bar height="100%" scroll-style="padding: 24px;">
      <Row :gap="[8]">
        <ConfigProvider :props="providedProps">
          <div style="padding: 10px">
            <div style="padding: 10px">
              <div>
                <Column :flex="1">
                  <div class="title">
                    <div class="title_color"></div>
                    <div class="title_content">一维</div>
                  </div>
                </Column>
                <Column>
                  <FormItem
                    label="1D单元检查："
                    prop="select"
                    :labelWidth="150"
                    :flex="1"
                  >
                    <RadioGroup v-model:value="radioValue">
                      <div flex>
                        <Radio
                          v-for="item in d1_Options"
                          :key="item.value"
                          :label="item.label"
                          :disabled="item.disabled"
                          :name="'select_radio'"
                        >
                          {{ item.label }}
                        </Radio>
                      </div>
                    </RadioGroup>
                  </FormItem>
                </Column>
                <Divider></Divider>
                <Column :flex="1">
                  <div class="title">
                    <div class="title_color"></div>
                    <div class="title_content">二维</div>
                  </div>
                </Column>
                <Column>
                  <FormItem
                    label="2D单元检查："
                    prop="select"
                    :labelWidth="150"
                    :flex="1"
                  >
                    <RadioGroup v-model:value="radioValue">
                      <div flex>
                        <Radio
                          v-for="item in d2_Options"
                          :key="item.value"
                          :label="item.label"
                          :disabled="item.disabled"
                          :name="'select_radio'"
                        >
                          {{ item.label }}
                        </Radio>
                      </div>
                    </RadioGroup>
                  </FormItem>
                </Column>
                <Divider></Divider>
                <Column :flex="1">
                  <div class="title">
                    <div class="title_color"></div>
                    <div class="title_content">三维</div>
                  </div>
                </Column>
                <Column>
                  <FormItem
                    label="3D单元检查："
                    prop="select"
                    :labelWidth="150"
                    :flex="1"
                  >
                    <RadioGroup v-model:value="radioValue">
                      <div flex>
                        <Radio
                          v-for="item in d3_Options"
                          :key="item.value"
                          :label="item.label"
                          :disabled="item.disabled"
                          :name="'select_radio'"
                        >
                          {{ item.label }}
                        </Radio>
                      </div>
                    </RadioGroup>
                  </FormItem>
                </Column>
                <Divider></Divider>
                <Column :flex="1">
                  <div class="title">
                    <div class="title_color"></div>
                    <div class="title_content">其他</div>
                  </div>
                </Column>
                <Column>
                  <FormItem
                    label="单元干涉穿透检查："
                    prop="select"
                    :labelWidth="150"
                    :flex="1"
                  >
                    <RadioGroup v-model:value="radioValue">
                      <div flex>
                        <Radio
                          v-for="item in misc_Options"
                          :key="item.value"
                          :label="item.label"
                          :disabled="item.disabled"
                          :name="'select_radio'"
                        >
                          {{ item.label }}
                        </Radio>
                      </div>
                    </RadioGroup>
                  </FormItem>
                </Column>
              </div>
            </div>
          </div>
        </ConfigProvider>
      </Row>
    </NativeScroll>
  </Modal>
</template>
<script setup lang="ts">
import { ref } from "vue";
import {
  Modal,
  Divider,
  RadioGroup,
  FormItem,
  ConfigProvider,
  Radio,
  NativeScroll,
  Row,
  Column,
  Message,
} from "cax-ui";
import { storeToRefs } from "pinia";
import { useCoreStore, _global } from "@/UI/store";
const coreStore = useCoreStore();

let { MeshCheckModalVueActive } = storeToRefs(coreStore);

let radioValue = ref();

const providedProps = {
  default: { clearable: true },
  formItem: { required: true },
};

const d1_Options = [
  {
    label: "一维重复对象",
    value: 1,
    disabled: false,
  },
  {
    label: "自由一维对象",
    value: 2,
    disabled: false,
  },
  {
    label: "自由一维节点",
    value: 3,
    disabled: false,
  },
  {
    label: "依赖",
    value: 4,
    disabled: true,
  },
  {
    label: "刚性环",
    value: 5,
    disabled: true,
  },
];
const d2_Options = [
  {
    label: "二维重复对象",
    value: 6,
    disabled: false,
  },
];
const d3_Options = [
  {
    label: "三维重复对象",
    value: 7,
    disabled: true,
  },
];
const misc_Options = [
  {
    label: "穿透",
    value: 8,
    disabled: true,
  },
];
const optionsArrays = [d1_Options, d2_Options, d3_Options, misc_Options];
function excuteMeshCheck() {
  const selectedOp = optionsArrays
    .flat()
    .find((item) => item.label === radioValue.value);
  if (selectedOp) {
    switch (selectedOp.value) {
      case 1:
        break;
      case 2:
        break;
      case 3:
        break;
      case 6:
        checkD2();
        break;
    }
  } else {
    Message.error("未选择操作!");
  }
}
// 检查二维重复单元
function checkD2() {
  _global.Engine.check.checkD2().then((res) => {
    alert(res.msg);
    coreStore.setBomInfo(res.bomInfo);
  });
}
</script>

<style scoped lang="less">
:deep(.vxp-form) {
  display: flex;
  align-items: center;
}
.title {
  display: flex;
  align-items: center;
  margin-bottom: 16px;

  .title_color {
    width: 4px;
    height: 12px;
    background: #339af0;
    margin-right: 8px;
  }
  .title_content {
    opacity: 1;
    font-family: PingFang SC;
    font-size: 14px;
    font-weight: 600;
    line-height: 22px;
    letter-spacing: 0em;
    font-variation-settings: "opsz" auto;
    /* content/主要一级primary */
    /* 样式描述：--vxp-content-color-primary */
    color: #212529;
  }
}
</style>
